home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Aplikacje_64-bitowe / Mixxx / mixxx-1.9.0-win64.exe / midi / Hercules DJ Control MP3 e2-scripts.js < prev    next >
Text File  |  2011-02-04  |  18KB  |  591 lines

  1. function HerculesMP3e2 () {}
  2.  
  3. // Control schema: http://blog.ebruni.it/blog/wp-content/uploads/2010/01/Hercules-mp3e2-schema-comandi.jpg
  4.  
  5. // Image: http://www.hablarcom.com.br/Imagens/arquivos/jptech/DJ_control_MP3_2_frente.jpg
  6.  
  7. // Explaination: http://www.mixxx.org/wiki/doku.php/hercules_dj_control_mp3_e2
  8.  
  9.  
  10.  
  11. // Number of the standard RPM value. Lower values increase de sensitivity as the really records.
  12. standardRpm = 33.33;
  13.  
  14. // The alpha value for the filter (start with 1/8 (0.125) and tune from there)
  15. alpha = 1/8;
  16.  
  17. // The beta value for the filter (start with alpha/32 and tune from there)
  18. beta = alpha/20;
  19.  
  20. // Timer to disable the scratch if the "jog wheel" is stopped for "x" milliseconds (default = 60)
  21. scratchResetTime = 60;
  22.  
  23. // Seconds to the end of track after which cue button blink (default = 30)
  24. secondsBlink = 30;  
  25.  
  26. // Tune the jog sensitivity when the scratch mode is disabled (default = 1, increase for increase the sensitivity
  27. jogSensitivity = 0.8;
  28.  
  29.  
  30.  
  31. superButtonHold = 0;
  32. scratchButton = 0;
  33. scratchMode = 0;
  34. scratchTimer = 0;
  35. wheelMove = [0,0];
  36. pitchIncrementRelative = 0;
  37. //scratchFactor = 0;
  38. //jogPitchFactor = 0;
  39.  
  40. /*HerculesMP3e2.controls = {
  41.     "inputs": {
  42.     0x11: { "channel": 1, "name": "loadA",         "type": "button" },
  43.     0x25: { "channel": 2, "name": "loadB",         "type": "button" },
  44.     0x0B: { "channel": 1, "name": "pitchbend+",     "type": "button" },
  45.     0x0A: { "channel": 1, "name": "pitchbend-",     "type": "button" },
  46.     0x1F: { "channel": 2, "name": "pitchbend+",     "type": "button" },
  47.     0x1E: { "channel": 2, "name": "pitchbend-",     "type": "button" },
  48.     0x12: { "channel": 1, "name": "sync",             "type": "button" },
  49.     0x26: { "channel": 2, "name": "sync",             "type": "button" },
  50.     0x13: { "channel": 1, "name": "mastertempo", "type": "button" },
  51.     0x27: { "channel": 2, "name": "mastertempo", "type": "button" },
  52.     0x0F: { "channel": 1, "name": "play",             "type": "button" },
  53.     0x23: { "channel": 2, "name": "play",             "type": "button" },
  54.     0x0E: { "channel": 1, "name": "cue",             "type": "button" },
  55.     0x22: { "channel": 2, "name": "cue",             "type": "button" },
  56.     0x2D: { "channel": 1, "name": "scratch",         "type": "button" },
  57.     0x2E: { "channel": 1, "name": "automix",         "type": "button" },
  58.     0x01: { "channel": 1, "name": "K1",             "type": "button" },
  59.     0x02: { "channel": 1, "name": "K2",             "type": "button" },
  60.     0x03: { "channel": 1, "name": "K3",             "type": "button" },
  61.     0x04: { "channel": 1, "name": "K4",             "type": "button" },
  62.     0x05: { "channel": 1, "name": "K5",             "type": "button" },
  63.     0x06: { "channel": 1, "name": "K6",             "type": "button" },
  64.     0x07: { "channel": 1, "name": "K7",             "type": "button" },
  65.     0x08: { "channel": 1, "name": "K8",             "type": "button" },
  66.     0x15: { "channel": 2, "name": "K1",             "type": "button" },
  67.     0x16: { "channel": 2, "name": "K2",             "type": "button" },
  68.     0x17: { "channel": 2, "name": "K3",             "type": "button" },
  69.     0x18: { "channel": 2, "name": "K4",             "type": "button" },
  70.     0x19: { "channel": 2, "name": "K5",             "type": "button" },
  71.     0x1A: { "channel": 2, "name": "K6",             "type": "button" },
  72.     0x1B: { "channel": 2, "name": "K7",             "type": "button" },
  73.     0x1C: { "channel": 2, "name": "K8",             "type": "button" },
  74.     0x30: { "channel": 1, "name": "wheel",         "type": "pot" },
  75.     0x31: { "channel": 2, "name": "wheel",         "type": "pot" },
  76.     0x2C: { "channel": 1, "name": "folder",         "type": "button" },
  77.     0x2B: { "channel": 1, "name": "files",         "type": "button" },
  78.     },
  79. }; */
  80.  
  81. HerculesMP3e2.init = function (id) 
  82.     // Switch off all LEDs
  83.     for (i=1; i<95; i++) 
  84.     {
  85.         midi.sendShortMsg(0x90, i, 0x00);
  86.     }
  87.     
  88.     midi.sendShortMsg(0xB0,0x7F,0x7F);
  89.     
  90.     // Switch-on some LEDs for improve the usability
  91.     midi.sendShortMsg(0x90, 46, 0x7F);    // Automix LED
  92.     midi.sendShortMsg(0x90, 14, 0x7F);    // Cue deck A LED
  93.     midi.sendShortMsg(0x90, 34, 0x7F);    // Cue deck B LED
  94.     
  95.     engine.connectControl("[Channel1]", "playposition", "HerculesMP3e2.playPositionCue");
  96.     engine.connectControl("[Channel2]", "playposition", "HerculesMP3e2.playPositionCue");
  97.     engine.connectControl("[Channel1]", "loop_start_position", "HerculesMP3e2.loopStartSetLeds");
  98.     engine.connectControl("[Channel2]", "loop_start_position", "HerculesMP3e2.loopStartSetLeds");
  99.     engine.connectControl("[Channel1]", "loop_end_position", "HerculesMP3e2.loopEndSetLeds");
  100.     engine.connectControl("[Channel2]", "loop_end_position", "HerculesMP3e2.loopEndSetLeds");
  101. };
  102.  
  103.  
  104. HerculesMP3e2.shutdown = function (id) 
  105. {
  106.     // Switch off all LEDs
  107.     for (i=1; i<95; i++)
  108.     {
  109.         midi.sendShortMsg(0x90, i, 0x00);
  110.     }
  111. };
  112.  
  113. HerculesMP3e2.automix = function (midino, control, value, status, group) 
  114. {
  115.     // SHIFT BUTTON    
  116.     // The "Automix" button is used like a shift button. When this is hold
  117.     //    down, many commands of the console has another functions
  118.     
  119.     // Button pressed
  120.     if (value) 
  121.     {
  122.         superButtonHold = 1;
  123.         // Switch-on some LEDs
  124.         midi.sendShortMsg(0x90, 30, 0x7F);    // Pitchbend - DB
  125.         midi.sendShortMsg(0x90, 31, 0x7F);  // Pitchbend + DB
  126.         midi.sendShortMsg(0x90, 10, 0x7F);  // Pitchbend - DA
  127.         midi.sendShortMsg(0x90, 11, 0x7F);  // Pitchbend + DA
  128.         midi.sendShortMsg(0x90, 19, 0x7F);    // Master tempo DA 
  129.         midi.sendShortMsg(0x90, 39, 0x7F);  // Master tempo DB
  130.     }
  131.     // Button released
  132.     else
  133.     {
  134.         superButtonHold = 0;
  135.         // Switch-off some LEDs    
  136.         midi.sendShortMsg(0x90, 30, 0x00);  // Pitchbend - DB
  137.         midi.sendShortMsg(0x90, 31, 0x00);  // Pitchbend + DB
  138.         midi.sendShortMsg(0x90, 10, 0x00);  // Pitchbend - DA
  139.         midi.sendShortMsg(0x90, 11, 0x00);  // Pitchbend + DA
  140.         midi.sendShortMsg(0x90, 19, 0x00);    // Master tempo DA 
  141.         midi.sendShortMsg(0x90, 39, 0x00);  // Master tempo DB
  142.     }
  143. };
  144.  
  145.  
  146. // Enable/disable the flanger effect or enable/disable the keylock tempo if shifted
  147. HerculesMP3e2.masterTempo = function (midino, control, value, status, group) 
  148. {
  149.     if (superButtonHold == 1 && value && scratchMode == 0)
  150.     {
  151.     engine.setValue(group, "keylock", (engine.getValue(group, "keylock") == 0) ? 1 : 0);
  152.     }
  153.     if (superButtonHold == 0 && value)
  154.     {
  155.     engine.setValue(group, "flanger", (engine.getValue(group, "flanger") == 0) ? 1 : 0);
  156.     }
  157. };
  158.  
  159. HerculesMP3e2.loadTrack = function (midino, control, value, status, group) 
  160. {
  161.     // Load the selected track in the corresponding deck only if the track is 
  162.     // paused
  163.  
  164.     if(value && engine.getValue(group, "play") != 1) 
  165.     {
  166.         engine.setValue(group, "LoadSelectedTrack", 1);
  167.         engine.setValue(group, "rate", 0);
  168.     }
  169.     else engine.setValue(group, "LoadSelectedTrack", 0);
  170. };
  171.  
  172. HerculesMP3e2.scroll = function (midino, control, value, status, group) 
  173. {
  174.     // Button "Files": up 10 tracks
  175.     // Button "Folder": down 10 tracks
  176.     // This function scroll up or down 10 tracks on the playlist, like the mouse
  177.     // scroll.
  178.  
  179.     if(control == 0x2C && value == 0x7F) 
  180.     {
  181.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  182.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  183.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  184.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  185.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  186.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  187.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  188.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  189.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  190.         engine.setValue("[Playlist]", "SelectPrevTrack", "1");
  191.         engine.setValue("[Playlist]", "SelectPrevTrack", "0");
  192.     }
  193.     if (control == 0x2B && value == 0x7F) 
  194.     {
  195.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  196.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  197.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  198.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  199.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  200.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  201.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  202.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  203.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  204.         engine.setValue("[Playlist]", "SelectNextTrack", "1");
  205.         engine.setValue("[Playlist]", "SelectNextTrack", "0");
  206.     }
  207. };
  208.  
  209. /*
  210. // NOT USED
  211.  
  212. HerculesMP3e2.holdTimer = function (group, first, second) {
  213.  
  214.     holdButtonFlag = 1;
  215.     engine.setValue(group, first, 0);    // Set "Off" the first function
  216.     engine.setValue(group, second, 1);    // Set "On" the second function
  217. };
  218.  
  219.  
  220. HerculesMP3e2.holdButton = function (group, value, first, second) {
  221.     // This feature allows you to perform a different function if a button is 
  222.     // pressed for 2 seconds. When the button is pressed, the first function is
  223.     // performed. If the button is hold down for 2 seconds, the second function
  224.     // is performed and the first function is disables.
  225.     
  226.     if (value) {
  227.         engine.setValue(group, first, 1);    // Set "On" the first function
  228.         holdTimerID = engine.beginTimer(2000, "HerculesMP3e2.holdTimer(\""+group+"\", \""+first+"\", \""+second+"\")", true);
  229.         }
  230.     else {
  231.         if (holdButtonFlag) {
  232.             engine.setValue(group, second, 0);    // Set "Off" the second function
  233.             holdButtonFlag = 0;
  234.         }
  235.         else {
  236.             engine.stopTimer(holdTimerID);
  237.             engine.setValue(group, first, 0);    // Set "Off" the first function
  238.         }
  239.     }
  240. }; 
  241.  
  242. */
  243.  
  244. HerculesMP3e2.keyButton = function (midino, control, value, status, group) 
  245. {
  246.     // Loop command for the first 4 Key, Hotcues command for the latest 4
  247.     
  248.     switch (control) 
  249.     {
  250.         // Loop buttons
  251.         case 0x01: case 0x15:      // K1, Loop in
  252.             if (superButtonHold == 1 && value) 
  253.             {
  254.             engine.setValue(group, "loop_start_position", -1);
  255.             engine.setValue(group, "loop_end_position", -1);
  256.             }
  257.             else engine.setValue(group, "loop_in", value ? 1 : 0);
  258.             break;
  259.         case 0x02: case 0x16:    // K2, Loop out
  260.             if (superButtonHold == 1 && value) 
  261.             {
  262.             engine.setValue(group, "loop_start_position", -1);
  263.             engine.setValue(group, "loop_end_position", -1);
  264.             }
  265.             else engine.setValue(group, "loop_out", value ? 1 : 0);
  266.             break;
  267.         case 0x03: case 0x17:    // K3, Reloop/Exit
  268.             engine.setValue(group, "reloop_exit", value ? 1 : 0); break;
  269.             break;
  270.         case 0x04: case 0x18:    // K4, Reloop/Exit
  271.             engine.setValue(group, "reloop_exit", value ? 1 : 0);
  272.             break;
  273.  
  274.         // Hotcue buttons:
  275.         // Simple press: go to the hotcue position
  276.         // Shift (hold down "Automix"): clear the hotcue
  277.         case 0x05: case 0x19 :    // K5
  278.             if (superButtonHold == 1) 
  279.             {
  280.                 //HerculesMP3e2.holdButton(group, value, "hotcue_1_set", "hotcue_1_clear");
  281.                 engine.setValue(group, "hotcue_1_clear", value ? 1 : 0);
  282.             }
  283.             else 
  284.             {
  285.                 engine.setValue(group, "hotcue_1_activate", value ? 1 : 0);
  286.             }
  287.             break;
  288.  
  289.         case 0x06: case 0x1A:    // K6
  290.             if (superButtonHold == 1) 
  291.             {
  292.                 //HerculesMP3e2.holdButton(group, value, "hotcue_2_set", "hotcue_2_clear");
  293.                 engine.setValue(group, "hotcue_2_clear", value ? 1 : 0);
  294.             }
  295.             else
  296.             {
  297.                 engine.setValue(group, "hotcue_2_activate", value ? 1 : 0);
  298.             }
  299.             break;
  300.  
  301.         case 0x07: case 0x1B:    // K7
  302.             if (superButtonHold == 1) 
  303.             {
  304.                 //HerculesMP3e2.holdButton(group, value, "hotcue_3_set", "hotcue_3_clear");
  305.                 engine.setValue(group, "hotcue_3_clear", value ? 1 : 0);
  306.             }
  307.             else
  308.             {
  309.                 engine.setValue(group, "hotcue_3_activate", value ? 1 : 0);
  310.             }
  311.             break;
  312.  
  313.         case 0x08: case 0x1C:    // K8
  314.             if (superButtonHold == 1) 
  315.             {
  316.                 //HerculesMP3e2.holdButton(group, value, "hotcue_4_set", "hotcue_4_clear");
  317.                 engine.setValue(group, "hotcue_4_clear", value ? 1 : 0);
  318.             }
  319.             else
  320.             {
  321.                 engine.setValue(group, "hotcue_4_activate", value ? 1 : 0);
  322.             }
  323.             break;
  324.         }
  325. };
  326.  
  327. HerculesMP3e2.knobIncrement = function (group, action, minValue, maxValue, centralValue, step, sign) 
  328. {
  329.     // This function allows you to increment a non-linear value like the volume's knob
  330.     // sign must be 1 for positive increment, -1 for negative increment
  331.     semiStep = step/2;
  332.     rangeWidthLeft = centralValue-minValue;
  333.     rangeWidthRight = maxValue-centralValue;
  334.     actual = engine.getValue(group, action);
  335.     
  336.     if (actual < 1) 
  337.     {
  338.         increment = ((rangeWidthLeft)/semiStep)*sign;
  339.     }
  340.     else if (actual > 1) 
  341.     {
  342.         increment = ((rangeWidthRight)/semiStep)*sign;
  343.     }
  344.     else if (actual == 1) 
  345.     {
  346.         increment = (sign == 1) ? rangeWidthRight/semiStep : (rangeWidthLeft/semiStep)*sign;
  347.     }
  348.  
  349.     if (sign == 1 && actual < maxValue)
  350.     {
  351.         newValue = actual + increment;
  352.     }
  353.     else if (sign == -1 && actual > minValue)
  354.     {
  355.         newValue = actual + increment;
  356.     }
  357.     
  358.     return newValue;
  359. };
  360.  
  361. HerculesMP3e2.pitch = function (midino, control, value, status, group) 
  362. {
  363.     // Simple: pitch slider
  364.     // Shifted: Headphone volume and pre/main
  365.     
  366.     if (superButtonHold == 1) 
  367.     {
  368.         sign = (value == 0x01) ? 1 : -1;
  369.         
  370.         if (group == "[Channel1]") 
  371.         {
  372.             newValue = HerculesMP3e2.knobIncrement("[Master]", "headVolume", 0, 5, 1, 30, sign);
  373.             engine.setValue("[Master]", "headVolume", newValue);
  374.         }
  375.         if (group == "[Channel2]") 
  376.         {
  377.             newValue = HerculesMP3e2.knobIncrement("[Master]", "headMix", -1, 1, 0, 20, sign);
  378.             engine.setValue("[Master]", "headMix", newValue);
  379.         }
  380.     }
  381.     else
  382.     {
  383.         engine.setValue(group, (value==1) ? "rate_perm_up" : "rate_perm_down", 1);
  384.         engine.setValue(group, (value==1) ? "rate_perm_up" : "rate_perm_down", 0);
  385.     }
  386.     
  387. };
  388.  
  389. HerculesMP3e2.pitchbend = function (midino, control, value, status, group) 
  390. {
  391.     // Simple: temporary pitch adjust
  392.     // Shift:  pregain adjust
  393.     if (superButtonHold == 1 && value) 
  394.     {
  395.         // Pitchbend +
  396.         if (control == 0x0B || control == 0x1F) 
  397.         {
  398.             newValue = HerculesMP3e2.knobIncrement(group, "pregain", 0, 4, 1, 20, 1);
  399.             engine.setValue(group, "pregain", newValue);
  400.         }
  401.         // Pitchbend -
  402.         else 
  403.         {
  404.             newValue = HerculesMP3e2.knobIncrement(group, "pregain", 0, 4, 1, 20, -1);
  405.             engine.setValue(group, "pregain", newValue);
  406.         }
  407.     }
  408.     else
  409.     {
  410.         // Pitchbend +
  411.         if (control == 0x0B || control == 0x1F) 
  412.         {
  413.             engine.setValue(group, "rate_temp_up", value ? 1 : 0);
  414.         }
  415.         // Pitchbend -
  416.         else 
  417.         {
  418.             engine.setValue(group, "rate_temp_down", value ? 1 : 0);
  419.         }
  420.     }
  421. };
  422.  
  423.         
  424. HerculesMP3e2.cue = function (midino, control, value, status, group) 
  425. {
  426.     // Don't set Cue accidentaly at the end of the song
  427.     if(engine.getValue(group, "playposition") <= 0.97) 
  428.     {
  429.         engine.setValue(group, "cue_default", value ? 1 : 0);
  430.     }
  431.     else
  432.     {
  433.         engine.setValue(group, "cue_preview", value ? 1 : 0);
  434.     }
  435. };
  436.  
  437. HerculesMP3e2.scratch = function (midino, control, value, status, group) 
  438. {
  439.     if (value) 
  440.     {
  441.         if(scratchMode == 0) 
  442.         {
  443.         // Enable the scratch mode on the corrisponding deck and start the timer
  444.             scratchMode = 1;
  445.             scratchTimer = engine.beginTimer(scratchResetTime, "HerculesMP3e2.wheelOnOff()");    
  446.             midi.sendShortMsg(0x90, 45, 0x7F); // Switch-on the sync led
  447.             engine.setValue("[Channel1]", "keylock", 0);
  448.             engine.setValue("[Channel2]", "keylock", 0);
  449.         
  450.         }
  451.         else 
  452.         {
  453.         // Disable the scratch mode on the corrisponding deck and stop the timer
  454.             scratchMode = 0;
  455.             engine.stopTimer(scratchTimer);
  456.             midi.sendShortMsg(0x90, 45, 0x00); // Switch-off the sync led
  457.         }
  458.     
  459.     }
  460. };
  461.  
  462. HerculesMP3e2.sync = function (midino, control, value, status, group) 
  463. {
  464.         engine.setValue(group, "beatsync", value ? 1 : 0);
  465. };
  466.  
  467.  
  468. // This function is called every "scratchResetTime" seconds and checks if the wheel was moved in the previous interval 
  469. // (every interval last "scratchResetTime" seconds). If the wheel was moved enables the scratch mode, else disables it.
  470. // In this way I have made a simple workaround to simulate the touch-sensitivity of the other controllers.
  471.  
  472. HerculesMP3e2.wheelOnOff = function () {
  473.     
  474.     // Wheel Deck A
  475.     if (wheelMove[0]) engine.scratchEnable(1, 128, standardRpm, alpha, beta);
  476.     else engine.scratchDisable(1);
  477.     wheelMove[0] = 0;
  478.     //Wheel Deck B
  479.     if (wheelMove[1]) engine.scratchEnable(2, 128, standardRpm, alpha, beta);
  480.     else engine.scratchDisable(2);
  481.     wheelMove[1] = 0;
  482. };
  483.  
  484.  
  485. HerculesMP3e2.jogWheel = function (midino, control, value, status, group) 
  486. {
  487.     var deck = (group == "[Channel1]") ? 1 : 2;
  488.     
  489.     // This function is called everytime the jog is moved
  490.     if (value == 0x01) 
  491.     {
  492.         if (scratchMode) {
  493.             engine.scratchTick(deck, 1);
  494.             wheelMove[deck-1] = 1;
  495.         }
  496.         else
  497.             engine.setValue(group, "jog", jogSensitivity);
  498.     }
  499.     else 
  500.     {
  501.         if (scratchMode) {
  502.             engine.scratchTick(deck, -1);
  503.             wheelMove[deck-1] = 1;
  504.         }
  505.         else
  506.             engine.setValue(group, "jog", -jogSensitivity); 
  507.     }
  508. };
  509.  
  510.  
  511. // This function switch-on the blinking of the cue led when the track is going to end and switch off the led 
  512. // when the track is ended
  513. HerculesMP3e2.playPositionCue = function (playposition, group) {
  514.     
  515.     var secondsToEnd = engine.getValue(group, "duration") * (1-playposition);
  516.     
  517.     if (secondsToEnd > secondsBlink) { 
  518.         if (group == "[Channel1]") {
  519.             midi.sendShortMsg(0x90,14,0x7F); // Switch-on Cue Led
  520.             midi.sendShortMsg(0x90,62,0x00); // Switch-off  Cue Blink
  521.         }
  522.         else {
  523.             midi.sendShortMsg(0x90,34,0x7F);
  524.             midi.sendShortMsg(0x90,82,0x00);
  525.         }
  526.         
  527.     }
  528.  
  529.     if (secondsToEnd < secondsBlink && secondsToEnd > 1) { // The song is going to end
  530.         if (group == "[Channel1]") {
  531.             midi.sendShortMsg(0x90,14,0x00);  // Switch-off Cue Led
  532.             midi.sendShortMsg(0x90,62,0x7F);  // Switch-on  Cue Blink
  533.         }
  534.         else {
  535.             midi.sendShortMsg(0x90,34,0x00);
  536.             midi.sendShortMsg(0x90,82,0x7F);
  537.         }
  538.     }
  539.     
  540.     if (secondsToEnd < 1) { // The song is finished
  541.         if (group == "[Channel1]") {
  542.             midi.sendShortMsg(0x90,14,0x00); // Switch-off Cue Led and blink
  543.             midi.sendShortMsg(0x90,62,0x00);
  544.         }
  545.         else {
  546.             midi.sendShortMsg(0x90,34,0x00);
  547.             midi.sendShortMsg(0x90,82,0x00);
  548.         }
  549.     }
  550.         
  551.  
  552. };
  553.  
  554. // Switch-on the K1 Led if the loop start is set
  555. HerculesMP3e2.loopStartSetLeds = function (loopStartPos, group) 
  556. {
  557.     if (group == "[Channel1]") 
  558.     {
  559.         if (loopStartPos != -1) midi.sendShortMsg(0x90,1,0x7F);
  560.         else midi.sendShortMsg(0x90,1,0x00);
  561.     }
  562.     else    
  563.     {
  564.         if (loopStartPos != -1) midi.sendShortMsg(0x90,21,0x7F);
  565.         else midi.sendShortMsg(0x90,21,0x00);
  566.     }
  567. }
  568.  
  569. // Switch-on the K2 Led if the loop end is set
  570. HerculesMP3e2.loopEndSetLeds = function (loopEndPos, group) 
  571. {
  572.     if (group == "[Channel1]") 
  573.     {
  574.         if (loopEndPos != -1) midi.sendShortMsg(0x90,2,0x7F);
  575.         else midi.sendShortMsg(0x90,2,0x00);
  576.     }
  577.     else    
  578.     {
  579.         if (loopEndPos != -1) midi.sendShortMsg(0x90,22,0x7F);
  580.         else midi.sendShortMsg(0x90,22,0x00);
  581.     }
  582. }
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.